<!DOCTYPE html>
<html class="signin no-js" lang="${lang!}">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <meta name="description" content="${app_name!}">
    <title>${msg['store.system.title']}--${app_name!}</title>
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/stepy/jquery.stepy.css">
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/font-awesome.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/themify-icons.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/animate.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/skins/palette.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/main.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/panel.css">
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/jstree/themes/default/style.min.css">
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/treetable/jquery.treetable.css">
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/datatables/css/dataTables.bootstrap.css">
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/chosen/chosen.min.css">
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/bootstrap-tokenfield/css/tokenfield-typeahead.css">
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/bootstrap-tokenfield/css/bootstrap-tokenfield.css">
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/bootstrap-datepicker/css/bootstrap-datepicker3.min.css">
    <link rel="stylesheet" href="${base!}/assets/platform/vendor/x-editable/bootstrap3-editable/css/bootstrap-editable.css">
    <!--[if lt IE 9]>
    <script src="${base!}/assets/platform/scripts/html5shiv.js"></script>
    <script src="${base!}/assets/platform/scripts/respond.min.js"></script>
    <script src="${base!}/assets/platform/scripts/json.js"></script>
    <![endif]-->
    <!--# if(@shiro.getPrincipalProperty('loginTheme')!=null){ #-->
    <link rel="stylesheet" href="${base!}/assets/platform/styles/skins/${@shiro.getPrincipalProperty('loginTheme')}" id="skin">
    <!--# }else{ #-->
    <link rel="stylesheet" href="${base!}/assets/platform/styles/skins/palette.css" id="skin">
    <!--# } #-->
    <script src="${base!}/assets/platform/vendor/jquery/jquery.min.js"></script>
    <script src="${base!}/assets/platform/vendor/bootstrap-tokenfield/bootstrap-tokenfield.min.js"></script>
    <script src="${base!}/assets/platform/vendor/bootstrap-star-rating/js/star-rating.js" type="text/javascript" ></script>
    <script src="${base!}/assets/platform/vendor/template.js" type="text/javascript"></script>
    <script type="text/javascript">
        var base = '${base!}';
    </script>
</head>

<section class="content-wrap bg-white">
    <header class="header navbar bg-white shadow">
        <!--<div class="btn-group tool-button">-->
            <!--<a id="add" class="btn btn-primary navbar-btn" href="${base}/store/member/company/add" data-pjax><i class="ti-plus"></i> ${msg['globals.button.add']}</a>-->
            <!--<button class="btn btn-danger navbar-btn" onclick="delCheck()"><i class="ti-close"></i> ${msg['globals.button.delete.more']}</button>-->
        <!--</div>-->
        <div class="btn-group tool-button" style="padding-top: 8px;">
            <form class="form-inline js-search-form" >
                <div class="form-group">
                    <label class="control-label"></label>
                    <input type="text" class="form-control" name="courierCompanyName" id="courierCompanyName" placeholder="物流公司名称" />
                </div>
                <div class="form-group">
                    <button type="button" id="searchBtn" class="btn btn-primary js-search-ok" >${msg['globals.button.search']}</button>
                </div>
            </form>
        </div>
    </header>
    <div class=panel-body style="padding-top: 50px;">
        <div class="table-responsive no-border"  style="min-height: 500px;">
            <table class="table table-bordered table-striped mg-t datatable">
                <thead>
                    <tr>
                            <th>${msg['courier.company.column.courierCompanyKey']}</th>
                            <th>${msg['courier.company.column.courierCompanyName']}</th>
                            <th>${msg['globals.table.column.operation']}</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</section>
<div id="dialogDelete" class="modal fade bs-modal-sm" tabindex="-2" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">${msg['globals.button.delete']}</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-xs-12">
                        ${msg['globals.button.delete.notice']}
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">${msg['globals.button.cancel']}</button>
                <button id="okDel" type="button" class="btn btn-primary" data-loading-text="${msg['globals.button.delete.tip']}">${msg['globals.button.confirm']}</button>
            </div>
        </div>
    </div>
</div>
<div id="dialogDetail" class="modal fade bs-modal-sm" tabindex="-3" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
    </div>
</div>

<!--script-->
<script src="${base!}/assets/platform/vendor/modernizr.js"></script>
<script src="${base!}/assets/platform/scripts/jquery.pjax.js"></script>
<script src="${base!}/assets/platform/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="${base!}/assets/platform/vendor/jquery.form/jquery.form.js"></script>
<script src="${base!}/assets/platform/vendor/sortable/js/sortable.min.js"></script>
<script src="${base!}/assets/platform/vendor/nestable/jquery.nestable.js"></script>
<script src="${base!}/assets/platform/vendor/iCheck/icheck.js"></script>
<script src="${base!}/assets/platform/vendor/slimScroll/jquery.slimscroll.min.js"></script>
<script src="${base!}/assets/platform/vendor/jquery.easing/jquery.easing.min.js"></script>
<script src="${base!}/assets/platform/vendor/appear/jquery.appear.js"></script>
<script src="${base!}/assets/platform/vendor/fastclick.js"></script>
<script src="${base!}/assets/platform/vendor/jquery-countTo/jquery.countTo.js"></script>
<script src="${base!}/assets/platform/scripts/toast.js"></script>
<script src="${base!}/assets/platform/vendor/chosen/chosen.jquery.min.js"></script>
<script src="${base!}/assets/platform/vendor/treetable/jquery.treetable.js"></script>
<script src="${base!}/assets/platform/vendor/datatables/js/jquery.dataTables.min.js"></script>
<script src="${base!}/assets/platform/vendor/datatables/js/dataTables.bootstrap.js"></script>
<script src="${base!}/assets/platform/vendor/jstree/jstree.min.js"></script>
<script src="${base!}/assets/platform/vendor/switchery/switchery.min.js"></script>

<script src="${base!}/assets/platform/vendor/stepy/jquery.stepy.js"></script>
<script src="${base!}/assets/platform/vendor/stepy/jquery.stepy.min.js"></script>
<script src="${base!}/assets/platform/vendor/jquery-validation/jquery.validate.min.js"></script>
<script src="${base!}/assets/platform/vendor/iCheck/icheck.min.js"></script>
<script src="${base!}/assets/platform/vendor/chosen/chosen.jquery.min.js"></script>
<script src="${base!}/assets/platform/vendor/uploadifive/jquery.uploadifive.min.js"></script>

<script src="${base!}/assets/platform/vendor/bootstrap-datepicker/js/bootstrap-datetimepicker.min.js"></script>
<script src="${base!}/assets/platform/vendor/bootstrap-datepicker/js/bootstrap-datetimepicker.fr.js"></script>
<script src="${base!}/assets/common/vendor/city-picker/js/data.86.all.js"  type="text/javascript"></script>
<script src="${base!}/assets/common/vendor/city-picker/js/picker.86.js"  type="text/javascript"></script>
<script src="${base!}/assets/platform/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="${base!}/assets/platform/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.${lang!}.min.js"></script>
<script src="${base!}/assets/platform/vendor/sortable/js/sortable.min.js"></script>
<script src="${base!}/assets/platform/vendor/sparkline/jquery.sparkline.min.js"></script>
<script src="${base!}/assets/platform/vendor/x-editable/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<script src="${base!}/assets/platform/vendor/jquery.placeholder.js"></script>
<script src="${base!}/assets/platform/vendor/moment/moment.min.js"></script>
<script src="${base!}/assets/platform/vendor/moment/locale/${lang!}.js"></script>
<script src="${base!}/assets/platform/vendor/parsleyjs/parsley.min.js"></script>
<script src="${base!}/assets/platform/vendor/parsleyjs/locale/${lang!}.js"></script>
<script src="${base!}/assets/platform/scripts/form.js"></script>
<script src="${base!}/assets/platform/scripts/offscreen.js"></script>
<script src="${base!}/assets/store/scripts/main.js"></script>
<script src="${base!}/assets/platform/scripts/page.js"></script>
<script src="${base!}/assets/platform/scripts/date.js"></script>
<script src="${base!}/assets/platform/vendor/select2/js/select2.min.js" type="text/javascript"></script>
<script src="${base!}/assets/platform/vendor/select2/js/i18n/${lang!'zh-CN'}.js" type="text/javascript"></script>
<script language="JavaScript">
    var datatable;
    var map = new Map();
    function initDatatable() {
        datatable = $('.datatable').DataTable({
            "dom": '<"toolbar">frtip',
            "searching":false,
            "processing": false,
            "serverSide": true,
            "select": true,
            "ordering": true,
            "language": {
                "url": "${base}/assets/platform/vendor/datatables/locale/${lang}.json"
            },
            "preDrawCallback": function () {
                sublime.showLoadingbar($(".main-content"));
            },
            "drawCallback": function () {
                sublime.closeLoadingbar($(".main-content"));
            },
            "ajax": {
                "url": "${base}/store/member/company/data",
                "type": "post",
                "data": function (d) {
                    d.courierCompanyName=$("#courierCompanyName").val();
                }
            },
            "order": [[0, "desc"]],
            "columns": [
                    {"data": "courierCompanyKey", "bSortable": true},
                    {"data": "courierCompanyName", "bSortable": true},
            ],
            "columnDefs": [
                {
                    "render": function (data, type, row) {
                        // return '<div class="btn-group"><button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">' +
                        //         ' <i class="ti-settings"></i> <span class="ti-angle-down"></span></button><ul class="dropdown-menu" role="menu">' +
                        //         '<li><a href="${base}/store/member/company/detail/' + row.id + '" data-toggle="modal" data-target="#dialogDetail">${msg["globals.button.detail"]}</a></li>' +
                        //         '<li><a href="${base}/store/member/company/edit/' + row.id + '" data-pjax>${msg["globals.button.update"]}</a></li>' +
                        //         '<li class="divider"></li>' +
                        //         '<li><a href="javascript:;" onclick="del(\'' + row.id + '\')">${msg["globals.button.delete"]}</a></li>' +
                        //         '</ul></div>';
                        map.set(row.courierCompanyKey,row.courierCompanyName);
                        return '<a class="btn btn-primary navbar-btn" href="javascript:;" onclick="select(\'' + row.courierCompanyKey + '\')">选择</a>';
                    },
                    "targets": 2
                }
            ]
        });
        datatable.on('click', 'tr', function () {
            $(this).toggleClass('selected');
        });
        $("#searchBtn").on('click', function () {
            datatable.ajax.reload();
        });
    }






    //选择物流公司
    function select(key,name){
        window.parent.$("#company").val(map.get(key));
        window.parent.$("#expressId").val(key);
        parent.layer.closeAll();
    }









    function del(id) {
        var dialog = $("#dialogDelete");
        dialog.modal("show");
        dialog.find("#okDel").unbind("click");
        dialog.find("#okDel").bind("click", function (event) {
            var btn = $(this);
            btn.button("loading");
            $.post("${base}/store/member/company/delete/" + id, {}, function (data) {
                if (data.code == 0) {
                    datatable.ajax.reload(null,false);
                } else {
                    Toast.error(data.msg);
                }
                btn.button("reset");
                dialog.modal("hide");
            }, "json");
        });
    }





    function delCheck() {
        var chks = datatable.rows('.selected').data();
        if (chks.length > 0) {
            var ids = [];
            $.each(datatable.rows('.selected').data(), function (i, n) {
                ids.push(n.id);
            });
            var dialog = $("#dialogDelete");
            dialog.modal("show");
            dialog.find("#okDel").unbind("click");
            dialog.find("#okDel").bind("click", function (event) {
                var btn = $(this);
                btn.button("loading");
                $.post("${base}/store/member/company/delete", {ids: ids.toString()}, function (data) {
                    if (data.code == 0) {
                        datatable.ajax.reload(null,false);
                    } else {
                        Toast.error(data.msg);
                    }
                    btn.button("reset");
                    dialog.modal("hide");
                }, "json");
            });
        } else {
            Toast.warning("${msg['globals.button.delete.select']}");
        }
    }
    $(function () {
        initDatatable();
        $("#dialogDetail").on("hidden.bs.modal", function () {
            $(this).removeData("bs.modal");
        });

        $("body").css("background","white");
    });
</script>
